package com.atguigu.gmall;

import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient1;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;
import org.springframework.util.ClassUtils;

public class FastDFDemo {
    public static void main(String[] args) throws Exception{
        //开始上传文件
        String path = ClassUtils.getDefaultClassLoader().getResource("fdfs_client.conf").getPath();
        //D:\Java_code\gmall-210601\gmall-parent\service\service-product\src\main\resources\fdfs_client.conf
        //init 底层IO流 读取你的指定的文件 IO流不认识相对路径 只认识绝对路径
        ClientGlobal.init(path);
        //1.上传链接请求
        TrackerClient trackerClient = new TrackerClient();
        //2.链接Tracker
        TrackerServer trackerServer = trackerClient.getConnection();
        //3.StorageClient1 升级版
        StorageClient1 storageClient1 = new StorageClient1(trackerServer,null);
        //4.上传图片 meta：元数据信息 图片长度是多少 图片背景 图片描述
        String p = storageClient1.upload_file1("D:\\尚硅谷Java\\老师代码视频课件\\13.电商项目\\图片\\iphone13.jpg"
                , "jpg", null);
        System.out.println("http://192.168.100.129:8080/" + p);
        //  http://192.168.100.129:8080/group1/M00/00/00/wKhkgWGSL02Acz2xAAG8VI2qds8628.jpg


    }
}
